//
//  XMGTopicVoiceView.m
//  百思不得姐
//
//  Created by Mine on 16/8/17.
//  Copyright © 2016年 Min. All rights reserved.

/** 自定义声音view
 1.
 2.
 3.
 */

#import "XMGTopicVoiceView.h"
#import "XMGTopic.h"
#import "UIImageView+WebCache.h"

@interface XMGTopicVoiceView()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *playcountlabel;
@property (weak, nonatomic) IBOutlet UILabel *voicelengthLabel;
@end

@implementation XMGTopicVoiceView
+ (instancetype)voiceView
{
    return [[[NSBundle mainBundle]loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

- (void)awakeFromNib
{
    self.autoresizingMask = UIViewAutoresizingNone;
}

- (void)setTopic:(XMGTopic *)topic
{
    _topic = topic;
    
    // 图片
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:topic.large_image]];
    
    // 播放次数
    self.playcountlabel.text = [NSString stringWithFormat:@"%zd播放",topic.playcount];
    
    // 时长
    NSInteger minute = topic.voicetime / 60;    // 多少分钟
    NSInteger second = topic.voicetime % 60;    // 多少秒
    self.voicelengthLabel.text = [NSString stringWithFormat:@"%02zd:%02zd",minute,second];
}
@end
